package cn.source.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import cn.source.common.annotation.Log;
import cn.source.common.core.controller.BaseController;
import cn.source.common.core.domain.AjaxResult;
import cn.source.common.enums.BusinessType;
import cn.source.system.domain.DbMailConfig;
import cn.source.system.service.IDbMailConfigService;
import cn.source.common.utils.poi.ExcelUtil;
import cn.source.common.core.page.TableDataInfo;

/**
 * 邮件发送配置Controller
 * 
 * @author sourcebyte.vip
 * @date 2025-03-03
 */
@RestController
@RequestMapping("/db/mail/config")
public class DbMailConfigController extends BaseController
{
    @Autowired
    private IDbMailConfigService dbMailConfigService;

    /**
     * 查询邮件发送配置列表
     */
    @GetMapping("/list")
    public TableDataInfo list(DbMailConfig dbMailConfig)
    {
        startPage();
        List<DbMailConfig> list = dbMailConfigService.selectDbMailConfigList(dbMailConfig);
        return getDataTable(list);
    }


    /**
     * 新增邮件发送配置
     */
    @Log(title = "邮件发送配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DbMailConfig dbMailConfig)
    {
        dbMailConfigService.deleteAll();
        return toAjax(dbMailConfigService.insertDbMailConfig(dbMailConfig));
    }


}
